package lanou.giftsay_01.fragment.body;

import android.widget.ListView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import lanou.giftsay_01.R;
import lanou.giftsay_01.adapter.GlAdapter;
import lanou.giftsay_01.bean.GongLueSreachBean;
import lanou.giftsay_01.tools.BaseFragment;
import lanou.giftsay_01.tools.NetTool;
import lanou.giftsay_01.tools.URLValues;

/**
 * Created by dllo on 16/8/26.
 */
public class SearchGonglueFragment extends BaseFragment {

    private GlAdapter glAdapter;

    public SearchGonglueFragment() {
        EventBus.getDefault().register(this);
    }

    private ListView lv;

    @Override
    protected int setLayout() {
        return R.layout.searchgonglue_fragment;
    }

    @Override
    protected void initView() {
        lv = (ListView) getView().findViewById(R.id.searchgonglue_lv);
        glAdapter = new GlAdapter(mContext);


    }

    @Override
    protected void initData() {


    }
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getDate (String date){
        NetTool netTool = new NetTool();
        netTool.getNetData(URLValues.GONGLUE + date +URLValues.GONGLUE1, GongLueSreachBean.class, new NetTool.NetListener<GongLueSreachBean>() {
            @Override
            public void onSuccess(GongLueSreachBean gongLueSreachBean) {
                  glAdapter.setGongLueSreachBean(gongLueSreachBean);
                  lv.setAdapter(glAdapter);
            }

            @Override
            public void onError(String errorMsg) {

            }
        });

    }
}
